package com.gbq.util;

import com.gbq.redisVo.KafkaVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.UUID;

@Component
public class KafkaSender {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    public void sendMessage(){
        KafkaVo k = new KafkaVo();
        k.setId(System.currentTimeMillis());
        k.setMsg(UUID.randomUUID().toString());
        k.setSendTime(new Date());
        kafkaTemplate.send("test", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS")));
    }

}
